package com.chery.media.ui.radio

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.chery.media.R
import com.chery.media.library.extend.dp
import com.chery.media.library.extend.shape
import com.chery.media.library.extend.toColorInt

class RadioAdapter: BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_radio_collect) {

    var index = -1

    override fun convert(holder: BaseViewHolder, item: String) {
        holder.apply {
            setText(R.id.radioChannel, item)
            getView<View>(R.id.channelLayout).shape(if (index == layoutPosition) R.color.public_FF8A00.toColorInt() else R.color.public_FFFFFF_30.toColorInt(), 5.dp.toFloat())
            setImageResource(R.id.playStatus, if (index == layoutPosition) R.drawable.svg_play_anim else R.drawable.svg_play)
            setGone(R.id.leftEmptyView, layoutPosition == 0)
        }
    }

    fun setSelect(position: Int) {
        this.index = position
        notifyDataSetChanged()
    }

}